#pragma once

#include "EnumerationLiteral.h"

#include "Enumeration.h"

namespace uml {

EnumerationLiteral::EnumerationLiteral(const QString& umlType)
    : InstanceSpecification(umlType) {}

void EnumerationLiteral::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    InstanceSpecification::fromJson(json, errorList);
    classifier_ = JsonSerializable::create<Enumeration>(json.value("classifier"), errorList);

    enumeration_ = JsonSerializable::create<Enumeration>(json.value("enumeration"), errorList);

}

void EnumerationLiteral::toJson(QJsonObject& json) {
    InstanceSpecification::toJson(json);
    if (classifier_) {
        QJsonObject classifier_json;
        classifier_->toJson(classifier_json);
        json.insert("classifier", classifier_json);
    }
    if (enumeration_) {
        QJsonObject enumeration_json;
        enumeration_->toJson(enumeration_json);
        json.insert("enumeration", enumeration_json);
    }
}

/// <summary>
/// classifier getter
/// The classifier of this EnumerationLiteral derived to be equal to its
/// Enumeration.
/// </summary>
shared_ptr<Enumeration> EnumerationLiteral::classifier() const {
    return classifier_;
}

/// <summary>
/// classifier setter
/// The classifier of this EnumerationLiteral derived to be equal to its
/// Enumeration.
/// </summary>
void EnumerationLiteral::setClassifier(shared_ptr<Enumeration> value) {
    classifier_ = value;
}

/// <summary>
/// enumeration getter
/// The Enumeration that this EnumerationLiteral is a member of.
/// </summary>
shared_ptr<Enumeration> EnumerationLiteral::enumeration() const {
    return enumeration_;
}

/// <summary>
/// enumeration setter
/// The Enumeration that this EnumerationLiteral is a member of.
/// </summary>
void EnumerationLiteral::setEnumeration(shared_ptr<Enumeration> value) {
    enumeration_ = value;
}

} // namespace uml
